//
//  FMPlayerHeadView.m
//  XWZ_News_Work
//
//  Created by dllo on 16/1/12.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "FMPlayerHeadView.h"

@implementation FMPlayerHeadView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubview];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
}

- (void)createSubview
{
    self.backgroundColor = [UIColor whiteColor];
    
    self.imageBG = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
    self.imageBG.image = [UIImage imageNamed:@"audionews_play_bg"];

    
    [self addSubview:self.imageBG];
    
    
    self.imageV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.height - 120 * HEIGHT, self.frame.size.height - 120 * HEIGHT)];
    self.imageV.image = [UIImage imageNamed:@"audio_block_bg"];

    
    self.imageV.center = CGPointMake(self.frame.size.width / 2, self.frame.size.height / 2);
    self.imageV.layer.cornerRadius = self.imageV.frame.size.width / 2;
    self.imageV.layer.masksToBounds = YES;
    [self addSubview:self.imageV];
    
    
    self.buttonLeft = [UIButton buttonWithType:UIButtonTypeCustom];
    self.buttonLeft.frame = CGRectMake(self.imageV.frame.origin.x - (self.imageV.frame.size.width  * 5 / 12), self.imageV.frame.origin.y + self.imageV.frame.size.height / 2 - (self.imageV.frame.size.width / 6), (self.imageV.frame.size.width / 3 - 20 * WIDTH), (self.imageV.frame.size.width / 3 - 20 * WIDTH));
    
    [self.buttonLeft setImage:[UIImage imageNamed:@"iconfont-shangyishou-2"] forState:UIControlStateNormal];
    [self.buttonLeft addTarget:self action:@selector(leftAction:) forControlEvents:UIControlEventTouchUpInside];

    
    
    [self addSubview:self.buttonLeft];
    
    
    self.buttonRight = [UIButton buttonWithType:UIButtonTypeCustom];
    self.buttonRight.frame = CGRectMake(self.imageV.frame.size.width + self.imageV.frame.origin.x + (self.imageV.frame.size.width  * 5 / 12) - self.buttonLeft.frame.size.width, self.buttonLeft.frame.origin.y, self.buttonLeft.frame.size.width, self.buttonLeft.frame.size.height);
    [self.buttonRight setImage:[UIImage imageNamed:@"iconfont-xiayishou"] forState:UIControlStateNormal];
    [self.buttonRight addTarget:self action:@selector(rightAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.buttonRight];
    
    
    self.stop = [UIButton buttonWithType:UIButtonTypeCustom];

    self.stop.frame = CGRectMake(0, 0, self.buttonRight.frame.size.width * 2, self.buttonRight.frame.size.height * 2);
    self.stop.center = self.imageV.center;
    [self.stop setImage:[UIImage imageNamed:@"audionews_pause_button"] forState:UIControlStateNormal];
    [self.stop addTarget:self action:@selector(stopAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.stop];
    
    
}

- (void)leftAction:(UIButton *)sender
{
    [self.delegate lastAction];
}

- (void)rightAction:(UIButton *)sender
{
    [self.delegate nextAction];
}

- (void)stopAction:(UIButton *)sender
{
    [self.delegate playAction];
}

@end
